<?php if(!defined('HDPHP_PATH'))exit;C('SHOW_NOTICE',FALSE);?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title></title>

	<link rel="stylesheet" href="http://localhost/ZBZphp/wowsai/Static/admin/Bootstrap/Css/bootstrap.min.css" />
	<link rel="stylesheet" href="http://localhost/ZBZphp/wowsai/Static/admin/Css/common.css" />
	<script type="text/javascript" src='http://localhost/ZBZphp/wowsai/Static/admin/Js/jquery-1.7.2.min.js'></script>
	<!--百度编辑器载入的文件-->
	<script type="text/javascript" charset="utf-8" src="http://localhost/ZBZphp/wowsai/Static/ueditor1_4_3/ueditor.config.js"></script>
	<script type="text/javascript" charset="utf-8" src="http://localhost/ZBZphp/wowsai/Static/ueditor1_4_3/ueditor.all.min.js"> </script>
	<script type="text/javascript" charset="utf-8" src="http://localhost/ZBZphp/wowsai/Static/ueditor1_4_3/lang/zh-cn/zh-cn.js"></script>
	<script type="text/javascript">
	$(function(){
		getAttr="<?php echo U('getAttr');?>";
		oldCid=0;
	})
	</script>	
	<script type="text/javascript" src='http://localhost/ZBZphp/wowsai/Static/admin/Js/goods.js'></script>

	<style type="text/css">
	    #pic,#file0{display: none;}
	    .pic,.big{
	    	width: 120px;height: 30px;
	    	background: url(http://localhost/ZBZphp/wowsai/Static/admin/Images/upBtn.png) no-repeat;
	    	float: left;
	    }
	    .picImg,.bigImg{float: left;line-height: 29px;margin-left: 20px;}
	    .pic:hover,.big:hover{background: url(http://localhost/ZBZphp/wowsai/Static/admin/Images/upBtn.png) no-repeat 0 -30px;}
	</style> 
</head>
<body>
	<div class="container-fluid">
	<div class="row-fluid">
	<div class="span12">

	<form action="" method='post' enctype="multipart/form-data">
		<legend>添加商品</legend>
		<table class='table table-bordered table-hover'>
			<thead>
				<tr>
					<th colspan="2" class="btn btn-primary">基本信息</th>
				</tr>
			</thead>
			<tbody>
				<tr class="info">
					<td>所属分类</td>
					<td>
						<input type="hidden" name="tid" value='' />
						<select name="cid">
							<option value="0">-请选择-</option>
							<?php foreach ($cateData as $k=>$v){?>
								<option value="<?php echo $v['cid'];?>" tid="<?php echo $v['tid'];?>"><?php echo $v['_name'];?></option>
							<?php }?>	
						</select>
					</td>
				</tr>
				<tr class="info">
					<td>所属品牌</td>
					<td>
						<select name="bid">
							<option value="0">-请选择-</option>
							<?php foreach ($brandData as $k=>$v){?>
								<option value="<?php echo $v['bid'];?>"><?php echo $v['bname'];?></option>
							<?php }?>	
						</select>
					</td>
				</tr>
				<tr class="info">
					<td>商品名称</td>
					<td>
						<input type="text" name='gname' class="input-block-level" />
					</td>
				</tr>
				<tr class="info">
					<td>单位</td>
					<td>
						<input type="text" name='gunit' value='件'/>
					</td>
				</tr>
				<tr class="info">
					<td>市价场</td>
					<td>
						<input type="text" name='marketprice'/>
					</td>
				</tr>
				<tr class="info">
					<td>商城价</td>
					<td>
						<input type="text" name='shopprice'/>
					</td>
				</tr>
				<tr class="info">
					<td>总库存</td>
					<td>
						<input type="text" name='gsum'/>
					</td>
				</tr>
				<tr class="info">
					<td>点击次数</td>
					<td>
						<input type="text" name='click' value="0"/>
					</td>
				</tr>
			</tbody>
		</table>

		<p class="btn btn-primary">商品属性</p>
		<table class="table table-bordered table-hover" id='attr' class="info">
			
		</table>
		<p class="btn btn-primary">商品规格</p>
		<table class="table table-bordered table-hover" id='spec'>
			
		</table>

		<table class='table table-bordered'>
			<tr class="next_show">
				<th colspan="3" class="btn btn-primary next_show">列表图</th>
			</tr>
			<tr class="info">
				<td>上传图片</td>
				<td colspan="2">
					<label for="pic" class="pic"></label>
					<input type="file" name='pic' id='pic'/>
					<span class="picImg"></span>
					<br><img src="" style="display:none">
				</td>
			</tr>
		</table>
		
		<table class='table table-bordered'>
			<tr class="next_show">
				<th colspan="3" class="btn btn-primary">商品大图</th>
			</tr>
			<tr class="info">
				<td>上传图片</td>
				<td colspan="2">
					<label for="file0" class="big"></label>
					<input type="file" name='big' id='file0'/>
					<span class="picImg"></span>
					<br>
					<img src="" style="display:none" >
				</td>
			</tr>
		</table>
		
		<table class='table'>
			<tr class="next_show">
				<th class="btn btn-primary">商品详细</th>
			</tr>
			<tr class="next_show">
				<td>
					<script id="editor" type="text/plain" style="width:1024px;height:500px;" name="introduce"></script>
		    		<script>
		        		var ue = UE.getEditor('editor');
		    		</script>
				</td>
			</tr>
		</table>
		
		<input type="submit" value="确认添加" class="btn btn-primary btn-block btn-large" />
	</form>

	</div>
	</div>
	</div>
<script type="text/javascript">
$(function(){
//	给两个上传按钮绑定onchange事件
	$("#file0,#pic").change(function(){
		var objUrl = getObjectURL(this.files[0]) ;
		var value=$(this).val();
//		给span标签添加商品图片的名字
		$(this).siblings('span').html(value);
		console.log("objUrl = "+objUrl) ;
		if (objUrl) {
//			给图片添加src并显示
			$(this).siblings('img').hide().attr("src", objUrl).fadeIn(300) ;
		}
	}) ;
	//建立一個可存取到該file的url
	function getObjectURL(file) {
		var url = null ; 
		if (window.createObjectURL!=undefined) { // basic
			url = window.createObjectURL(file) ;
		} else if (window.URL!=undefined) { // mozilla(firefox)
			url = window.URL.createObjectURL(file) ;
		} else if (window.webkitURL!=undefined) { // webkit or chrome
			url = window.webkitURL.createObjectURL(file) ;
		}
		return url ;
	}
	
})
</script> 
</body>
</html>